package com.example.musicapi.dao;

import com.example.musicapi.entity.Notice;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface NoticeDao  extends JpaRepository<Notice, String> {

    Notice findDataById(String id);

    Page<Notice> findAll(Pageable pageable);

    Page<Notice> findAllById(Pageable pageable, String id);


    //  根据 key 进行模糊查询的分页方法
    @Query("SELECT n FROM Notice n WHERE n.title LIKE %:key%")
    Page<Notice> findBySearch(@Param("key")  String key, Pageable pageable);

}

